
#import "GeneralSprite.h"
#import "GameManager.h"

@implementation GeneralSprite

@synthesize spriteType, state;
@synthesize number;
@synthesize numberLabel;
@synthesize delegate;

-(id) init
{
    if( (self = [super init]) )
    {
        [self setSpriteType:kSPRITE_TYPE_NIL];
        [self setState:kSPRITE_STATE_IDLE];
        [self setNumberLabel:nil];  //Set to nil
        [self setNumber:-1];
    }
    
    return self;
}

-(void) dealloc
{
    [self setState:kSPRITE_STATE_NIL];
    [numberLabel release];
    [super dealloc];
}

#pragma mark To be Abstract Function
-(void) startCorrectEffect
{
    CCLOG(@"startCorrectEffect Should be inherited");
    [self doesNotRecognizeSelector:_cmd];
/*
    [self setState:kSPRITE_STATE_REMOVING];
    [self stopAllActions];
    [self unscheduleUpdate];
*/
}

-(void) startIncorrectEffect
{
    CCLOG(@"startIncorrectEffect Should be inherited");
    [self doesNotRecognizeSelector:_cmd];
    //No need to update state, since it's not removed
    //[self setState:kSPRITE_STATE_REMOVING];
}

-(void) startActionWithWave:(int)wave
{
    CCLOG(@"startActionWithWave Should be inherited");
    [self doesNotRecognizeSelector:_cmd];
}

/*
- (CGRect)rect
{
    CGSize s = [self.texture contentSize];
    return CGRectMake(-s.width / 2, -s.height / 2, s.width, s.height);
}

- (BOOL)containsTouchLocation:(UITouch *)touch
{
    return CGRectContainsPoint(self.rect, [self convertTouchToNodeSpaceAR:touch]);
}

- (void) onEnter  
{  
    [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES]; 
    [super onEnter];  
}  

- (void) onExit  
{  
    [[CCTouchDispatcher sharedDispatcher] removeDelegate:self];  
    [super onExit];  
}

#pragma mark To be Overrided Function
-(void) startCorrectEffect
{
    [self setState:kSPRITE_STATE_REMOVING];
    [self stopAllActions];
    [self unscheduleUpdate];
}

-(void) finishCorrectEffect
{
    [self setState:kSPRITE_STATE_REMOVED];
}

-(void) startIncorrectEffect
{
    //No need to update state, since it's not removed
    //[self setState:kSPRITE_STATE_REMOVING];
}

-(void) finishIncorrectEffect
{
    //No need to update state, since it's not removed
    //[self setState:kSPRITE_STATE_REMOVED];
}

-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
    //Check the condifion if it's able to be touched 
    
    //Only Playing is able to touch 
    if( [[GameManager sharedGameManager] gameState] != kGAME_STATE_PLAYING)
        return NO;
        
    if ( ![self containsTouchLocation:touch] ) 
    {
        return NO;
    }
    
    return YES; 
}

-(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event
{
}

-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
{
}

-(void) ccTouchCancelled:(UITouch *)touch withEvent:(UIEvent *)event
{
    [self ccTouchEnded:touch withEvent:event];
}
*/
@end
